package com.tuniu.agents.tools.flights.utils;

import com.tuniu.agents.tools.flights.enums.FlightToolEnum;
import com.tuniu.agents.util.I18nUtil;
import io.micrometer.common.util.StringUtils;

/**
 * Flight display message utility
 */
public class FlightMessageUtils {

    /**
     * Display message
     *
     * @param departureCityName Departure city
     * @param arrivalCityName   Arrival city
     * @param departureDate     Departure date
     * @return Display message content
     */
    public static String getShowMessage(String departureCityName, String arrivalCityName, String departureDate, String backDepartureDate, String conversationId) {
        String[] loadingStr = FlightToolEnum.FLIGHT_UTILS_LIST.getBefore().split(",");
        if (StringUtils.isEmpty(backDepartureDate)) {
            return I18nUtil.getMessage(conversationId, loadingStr[0], new Object[]{departureDate, departureCityName, arrivalCityName});
        } else {
            return I18nUtil.getMessage(conversationId, loadingStr[1], new Object[]{departureCityName, arrivalCityName, departureDate, backDepartureDate});
        }
    }

    //public static final String TOOL_AFTER_MESSAGE = "共找到 <span style=\"color:#32c45d;\">%s</span> 班航班，准备进行推荐";
    //public static final String TOOL_AFTER_MESSAGE_NO_FLIGHTS = "共找到 <span style=\"color:#32c45d;\">%s</span> 班航班";

    /**
     * Display quantity information
     * @return
     */
    public static String getToolMessage(int num, String conversationId) {
        String[] loadingStr = FlightToolEnum.FLIGHT_UTILS_LIST.getAfter().split(",");
        if (num == 0) {
            return I18nUtil.getMessage(conversationId, loadingStr[0], new Object[]{num});
        }
        return I18nUtil.getMessage(conversationId, loadingStr[1], new Object[]{num});
    }
}
